﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Matthew
{
    public partial class FrmSettings : Form
    {
        public FrmSettings()
        {
            InitializeComponent();
        }

        public void Initialize()
        {
            txtDBUsername.Text = Settings.DBUsername;
            txtDBPassword.Text = Settings.DBPassword;
            txtDBName.Text = Settings.DBName;
            txtSellerID.Text = Settings.SellerID;
            txtSchemaFileName.Text = Settings.InvoiceSchemaFileName;

            btnApply.Enabled = false;
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            AllFormClass.FormMenu.Show();
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            Settings.DBUsername = txtDBUsername.Text;
            Settings.DBPassword = txtDBPassword.Text;
            Settings.DBName = txtDBName.Text;
            Settings.SellerID = txtSellerID.Text;
            Settings.InvoiceSchemaFileName = txtSchemaFileName.Text;

            btnApply.Enabled = false;
        }

        private void txtBoxes_TextChanged(object sender, EventArgs e)
        {
            btnApply.Enabled = true;
        }

        private void btnLoadSchema_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                txtSchemaFileName.Text = openFileDialog.FileName;
            }
        }
    }
}
